package no.spk.util.inforama.web.controller;

import javax.servlet.http.HttpServletRequest;

import no.spk.util.inforama.service.InfoRamaService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author marius.breivik
 */
@Controller
public class InfoRamaWebController {
	
	private InfoRamaService service;
	
	public InfoRamaWebController() {
		// TODO Auto-generated constructor stub
	}
	
	@Autowired
	public InfoRamaWebController(InfoRamaService inforamaService) {
		this.service = inforamaService;
		System.out.println("InforamaService satt" + inforamaService);
	}
	
//	@RequestMapping("/Test.htm")
//	public ModelAndView deployables( HttpServletRequest request )throws ServletRequestBindingException{
//		ModelAndView mav = new ModelAndView("inforama");
//		String containerName = ServletRequestUtils.getRequiredStringParameter(request, "containerName");
//		mav.addObject("deployables", service.getDeployables( containerName ));
//		return mav;
//	}
	
	@RequestMapping("/inforama.htm")
	public ModelAndView containerNames( HttpServletRequest request )throws ServletRequestBindingException{
		ModelAndView mav = new ModelAndView("inforama");
		mav.addObject( "containerNames", service.getContainerNames() );
		return mav;
	}
}